#pragma once

#include <atlcrack.h>
#include <atlctrls.h>

#include <vector>
#include <string>

#include "atlcedlg.h"
#include "MemoEdit.h"

#include "resource.h"

#define DLG_FLAGS SHIDIF_SIZEDLGFULLSCREEN | SHIDIF_DONEBUTTON

class EditDialog : public CCEResizableDialog< EditDialog, DLG_FLAGS >
{
public:    

    EditDialog(const std::wstring &fName, bool unc) 
        : fileName(fName)
        , unicode(unc)
    {}

    typedef CCEResizableDialog< EditDialog, DLG_FLAGS > baseClass;
    enum { IDD = IDD_EDIT_DIALOG };

    BEGIN_MSG_MAP_EX(EditDialog)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        NOTIFY_CODE_HANDLER(GN_CONTEXTMENU, OnContextMenu)
        MESSAGE_HANDLER(WM_CLOSE, OnClose)
        MESSAGE_HANDLER(IDOK, OnClose)
        MESSAGE_HANDLER(IDCANCEL, OnClose)
        MSG_WM_SIZE(OnSize)
        CHAIN_MSG_MAP(baseClass)
    END_MSG_MAP()

    LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
    LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

	LRESULT OnContextMenu(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/);

    void OnSize(UINT, const CSize&);

protected:

    MemoEdit memoCtrl;
    
    const std::wstring fileName;
    const bool unicode;
};